home *** CD-ROM | disk | FTP | other *** search
- Path: castle.nando.net!news
- From: actuary@nando.net (Bill McCarthy)
- Newsgroups: comp.lang.c
- Subject: Re: What the hell is THIS?!
- Date: 13 Jan 1996 20:50:04 GMT
- Organization: News & Observer Public Access
- Message-ID: <4d95ts$fi0@castle.nando.net>
- References: <4d6rgh$rfu@abel.cc.sunysb.edu>
- Reply-To: actuary@nando.net (Bill McCarthy)
- NNTP-Posting-Host: vyger217.nando.net
- X-Newsreader: IBM NewsReader/2 v1.2
-
- In <4d6rgh$rfu@abel.cc.sunysb.edu>, bmadhusu@engws12.ic.sunysb.edu (Bommasamudram Madhusudan) writes:
- >hi guys;
- >
- >I'm going nuts trying to figure this out;
- >
- >Can someone explain what
- >
- > int (*p)[3] is?????
- >
- > Is this an array of pointers to integers
-
- No, that would be "int *p[3];"
-
- >
- > OR
- >
- > a pointer to an array of integers?? HELP!
-
- Bingo!
-
- >I can say things like:
- >
- >(*p)[0] = 3; for e.g, but when I print the value using:
- >
- > printf("%d",(*p)[0]) I get a core dump!
-
- Interesting. You can store to unallocated memory, but
- a fetch gives you a core dump. Time for a new compiler
- and/or operating system.
-
- The basic problem is that memory has only been allocated
- for a pointer to an array -- not for the array. Try out the
- following:
-
- #include <stdio.h>
-
- int main( void )
- {
- int arr[3];
- int (*p)[3] = arr;
-
- (*p)[0] = 3;
- printf("%d",(*p)[0]);
-
- return 0;
- }
-
- Bill McCarthy
- actuary@nando.net
- Wendell, NC USA
-
-